<?php
$backend=dirname(dirname(__FILE__));
$frontend=dirname($backend);
Yii::setPathOfAlias('backend', $backend);

$frontendArray=require($frontend.'/config/main.php');

$backendArray=array(
    'name'=>'KooCMS',
    'basePath' => $frontend,
    'controllerPath' => $backend.'/controllers',
    'viewPath' => $backend.'/views',
    'runtimePath' => $backend.'/runtime',
    
    'defaultController'=>'site/login',

    // autoloading model and component classes
    'import'=>array(
        'application.models.*',
        'application.components.*',
        'application.extensions.*',
        // 'application.extensions.nestedset.*',
        'application.modules.srbac.controllers.SBaseController',
        //'backend.models.*',
        'backend.components.*', //Notice these orders
    ),
    'components'=>array(
        'user'=>array(
            // enable cookie-based authentication
            'allowAutoLogin'=>true,
        ),
        'widgetFactory'=>array(
            'widgets'=>array(
                // Global settings for widgets
                'CLinkPager'=>array(
                    'header'=>'',
                    'firstPageLabel'=>'First',
                    'prevPageLabel'=>'Previous',
                    'nextPageLabel'=>'Next',
                    'lastPageLabel'=>'Last',
                ),
                'CGridView'=>array(
                    'summaryText'=>'<span class="loading"></span><span class="label">Displaying {start}-{end} of {count} result(s).</span>',
                    'cssFile'=>'',
                    'itemsCssClass'=>'table table-bordered table-striped items',
                    'template'=>'{summary}{items}{pager}',
                    'pagerCssClass'=>'pagination',
                    'pager'=>array(
                        'cssFile'=>'',
                    ),
                ),
                'CListView'=>array(
                    'summaryText'=>'<span class="loading"></span>Displaying {start}-{end} of {count} result(s).',
                ),
                'CDetailView'=>array(
                    'cssFile'=>'',
                    'htmlOptions'=>array(
                        'class'=>'table table-bordered table-striped',
                    ),
                ),
                'ETinyMce'=>array(
                    'useSwitch'=>false,
                    'editorTemplate'=>'full',
                    'options'=>array(
                        'theme'=>'advanced',
                        'skin'=>'o2k7',
                        'skin_variant'=>'silver',
                        'theme_advanced_resize_horizontal'=>false,
                        'remove_linebreaks'=>false,
                        'extended_valid_elements'=>'textarea[cols|rows|disabled|name|readonly|class]',
                        'theme_advanced_buttons1' => 'preview,bold,italic,underline,fontselect,fontsizeselect,link,justifyleft,justifycenter,justifyright,table,image,|,bullist,numlist,|,undo,redo,|,code,syntaxhl,fullscreen',
                        'theme_advanced_buttons2' => '',
                        'theme_advanced_buttons3' => '',
                    ),
                ),
            ),
        ),
        'urlManager'=>array(
			'urlFormat'=>'path',
            'showScriptName'=>true,
		),
    ),
    
    'modules'=>array(
		// Reset ths SRBAC layout path
        'srbac' => array(
            //'layout'=>'application.admin.views.layouts.main',
        ),
    ),
    
    // main is the default layout
    //'layout'=>'main',
    // alternate layoutPath
    //'layoutPath'=>dirname(dirname(__FILE__)).DIRECTORY_SEPARATOR.'views'.DIRECTORY_SEPARATOR.'layouts'.DIRECTORY_SEPARATOR,

);
if(!function_exists('w3_array_union_recursive'))
{
    /**
     * This function does similar work to $array1+$array2,
     * except that this union is applied recursively.
     * @param array $array1 - more important array
     * @param array $array2 - values of this array get overwritten
     * @return array
     */
    function w3_array_union_recursive($array1,$array2)
    {
        $retval=$array1+$array2;
        foreach($array1 as $key=>$value)
        {
            if(is_array($array1[$key]) && is_array($array2[$key]))
                $retval[$key]=w3_array_union_recursive($array1[$key],$array2[$key]);
        }
        return $retval;
    }
}

return w3_array_union_recursive($backendArray,$frontendArray);

